<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script src="${ctxStatic}/jquery/jquery-1.9.1.min.js"></script>
<script src="${ctxStatic}/jquery-qrcode/jquery.qrcode.min.js"></script>
<html>
<head>
<%@ include file="/WEB-INF/views/include/head.jsp"%>
<link rel="stylesheet" href="${ctxStatic}/css/list_erp.css">
<link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
<style>
	body{
		width: 100%;
		height: 100%;
		overflow-y: auto;
		overflow-x:hidden;
	}

	.materialContactTemp{
		padding-top: 40px;
	}
	
	td{
		padding: 20px 0;
	}
</style>
<script type="text/javascript">
	$(document).ready(function(){
		$("#orderNo").focus();
	});
	/**
	*	通过条形码获取订单返工换片信息
	*/
	function searchReworkInfo() {
		var url = "${ctx}/reworkInfo";
		var params = {
			"orderNo":$("#orderNo").val(),
			"imageFlag":"${imageFlag}"
		}
		$.post(url,params,function(result){
			$("#reworkHTML").html($(callBackHtml(result)).find("#reworkHTML").html());
			$("#orderNo").focus();
		},'html')
	}
	/**
	*	弹出换片画面 
	*/
	function popoJsp(fabricId,styleFabricNo,orderId,contractId,orderNO) {
		if ("${imageFlag}" == 1 && $("#reworkReason").val() == "") {
			alert("<spring:message code='rework_alert_pleaseSelectReworkReason'/>");
			return;
		}
		popup('950px','600px','${ctx}/changeImperfect?order.fabricId=' + fabricId 
									+'&order.styleFabricNo='+styleFabricNo
									+'&order.id='+orderId
									+'&order.contractID='+contractId
									+'&order.orderNO='+orderNO
									+'&reworkReason='+$("#reworkReason").val());
	}
	
	/**
	 * 扫码自动回车
	 */
	function  keyLogin(e) {
        var theEvent = window.event || e;
        var code = theEvent.keyCode || theEvent.which;
        if (e.key=='Enter') {
        	$("#searchBtn").click();
        } 
    }
	
	/* 选择返工原因   */
	function selectSeason(flag,obj){
		if (flag == 0) {
			obj.style.background = "#595959";
			$(obj).attr("onclick","selectSeason(1,this)");
			$("#reworkReason").val($("#reworkReason").val() + obj.value + ",");
		}else if (flag == 1) {
			obj.style.background = "#DDDDDD";
			$(obj).attr("onclick","selectSeason(0,this)");
			$("#reworkReason").val($("#reworkReason").val().replace((obj.value+","),""));
		}
	}
</script>
</head>
<body>
<div>
	<div style="top:20px;height: 50px;margin-top:20px;margin-bottom:30px;">
		<div style="width: 50%;float: left;margin-left:20px; margin-top: 10px;">
		<!-- 订单号 -->
			<p class="searchTxt" style="font-size: 37px;width: 30%;"><spring:message code='rework_orderNo'/>:</p>
			<div>
				<input type="text" id="orderNo" style="width: 150px;height: 40px;" value="" onkeydown="keyLogin(event);" onfocus="javascript:this.select();"/>
			</div>
		</div>
		<div style="width: 30%;float: right;margin-top: 10px;">
		<!-- 检索 -->
			<button id="searchBtn" style="width: 50%; height: 50px;margin-top:-10px;font-size: 26px;background:#595959;color:#ffffff;"  type="button" onclick="searchReworkInfo()"><spring:message code='rework_search'/></button>				
		</div>
	</div>
	<div id="reworkHTML">
		<div class="smOrderBox">
		<!-- 基本信息 -->
			<p style="font-size: 37px;"><spring:message code='rework_title_basicInfo'/></p>
			<hr>
			<div class="items clearfix" style="padding: 10px 0">
		       	<div class="clearfix" style="font-size: 32px;left: 5%;position: relative;">
		       	<!-- 合同号 -->
		            <p class="tit" style="width: 13%;"><spring:message code='rework_contractNo'/>:</p>
		            <p>${orderInfo.contractNo }</p>
		        </div>
			</div>
			<div class="items clearfix" style="padding: 10px 0">
		       	<div class="clearfix" style="font-size: 32px;left: 5%;position: relative;">
		       	<!-- 订单号 -->
		            <p class="tit" style="width: 13%;"><spring:message code='rework_orderNo'/>:</p>
		            <p>${orderInfo.orderNO }</p>
		        </div>
			</div>
			<div class="items clearfix" style="padding: 10px 0">
		       	<div class="clearfix" style="font-size: 32px;left: 5%;position: relative;">
		       	<!-- 生产号 -->
		            <p class="tit" style="width: 13%;"><spring:message code='rework_styleNo'/>:</p>
		            <p>${orderInfo.styleNo }</p>
		        </div>
			</div>
		</div>
		<div class="smOrderBox">
		<!-- 返工原因 -->
			<p style="font-size: 37px;"><spring:message code='rework_title_reason'/></p>
			<hr/>
			<c:choose>
				<c:when test="${imageFlag == 0 }">
					<c:forEach items="${itemList }" var="item" varStatus="status">
						<div class="items clearfix" style="padding: 10px 0;font-size: 30px;left: 5%;position: relative;">${status.count }.${item.qcItem }</div>
					</c:forEach>
				</c:when>
				<c:otherwise>
				<c:set value="REWORK_REASON" var="reworkReason"/>
					<c:forEach items="${fns:getDictList(reworkReason) }" var="item" varStatus="status">
						<button style="width:49%;height: 70px;font-size: 32px;border:none;border-radius:5px;margin-bottom:10px;background:#DDDDDD;color:#ffffff;" type="button" onclick="selectSeason(0,this);"
						value="${item.itemCode }-${item.itemValue }">${status.count}.${item.itemNameCn }</button>
					</c:forEach>
				</c:otherwise>
			</c:choose>
			<input type="hidden" id="reworkReason" value=""/>
		</div>
		<div class="smOrderBox">
		<!-- 换片 -->
			<c:choose>
				<c:when test="${imageFlag == 0 }">
					<p style="font-size: 37px;"><spring:message code='rework_title_changeImperfect_cloth'/></p>
				</c:when>
				<c:otherwise>
					<p style="font-size: 37px;"><spring:message code='rework_title_changeImperfect_tailor'/></p>
				</c:otherwise>
			</c:choose>
			<hr/>
			<c:if test="${orderInfo.styleFabricNo != null && orderInfo.styleFabricNo != ''}">
			<!-- 面料名称 -->
				<p class="tit left" style="width: 20%;font-size: 30px;left: 5%;position: relative;"><spring:message code='rework_materialName'/>:</p>
				<p class="tit left" style="width: 50%;font-size: 30px;">${orderInfo.styleFabricNo }</p>
				<div class="items clearfix left" style="padding: 10px 0;width:15%;">
				<!-- 换片 -->
					<button style="width: 100%; height: 50px;margin-top:-10px;font-size: 26px;background:#595959;color:#ffffff;"  type="button" onclick="popoJsp('${orderInfo.fabricId }','${orderInfo.styleFabricNo }','${orderInfo.id }','${orderInfo.contractID }','${orderInfo.orderNO }');"><spring:message code='rework_button_changeImperfect'/></button>
				</div>
			</c:if>
		</div>
	</div>
</div>
</html>